#include "test.h"
#include "lv_font_source_han_sans_bold.h" //中文字体的头文件

//=================在屏幕四个角创建按钮======================
void create_four_corner_buttons(void)
{
    /* 初始化默认状态的样式 */
    static lv_style_t style;
    lv_style_init(&style);

    lv_style_set_radius(&style, 3);
    lv_style_set_bg_opa(&style, LV_OPA_100);
    lv_style_set_bg_color(&style, lv_palette_main(LV_PALETTE_BLUE));
    lv_style_set_bg_grad_color(&style, lv_palette_darken(LV_PALETTE_BLUE, 2));
    lv_style_set_bg_grad_dir(&style, LV_GRAD_DIR_VER);
    lv_style_set_border_opa(&style, LV_OPA_40);
    lv_style_set_border_width(&style, 2);
    lv_style_set_border_color(&style, lv_palette_main(LV_PALETTE_GREY));
    lv_style_set_shadow_width(&style, 8);
    lv_style_set_shadow_color(&style, lv_palette_main(LV_PALETTE_GREY));
    lv_style_set_shadow_ofs_y(&style, 8);
    lv_style_set_outline_opa(&style, LV_OPA_COVER);
    lv_style_set_outline_color(&style, lv_palette_main(LV_PALETTE_BLUE));
    lv_style_set_text_color(&style, lv_color_white());
    lv_style_set_pad_all(&style, 10);

    /* 初始化按下状态的样式 */
    static lv_style_t style_pr;
    lv_style_init(&style_pr);
    lv_style_set_outline_width(&style_pr, 30);
    lv_style_set_outline_opa(&style_pr, LV_OPA_TRANSP);
    lv_style_set_translate_y(&style_pr, 5);
    lv_style_set_shadow_ofs_y(&style_pr, 3);
    lv_style_set_bg_color(&style_pr, lv_palette_darken(LV_PALETTE_BLUE, 2));
    lv_style_set_bg_grad_color(&style_pr, lv_palette_darken(LV_PALETTE_BLUE, 4));

    /* 添加过渡动画 */
    static lv_style_transition_dsc_t trans;
    static lv_style_prop_t props[] = {LV_STYLE_OUTLINE_WIDTH, LV_STYLE_OUTLINE_OPA, 0};
    lv_style_transition_dsc_init(&trans, props, lv_anim_path_linear, 300, 0, NULL);
    lv_style_set_transition(&style_pr, &trans);

    /* 创建左上角按钮 */
    lv_obj_t * btn_top_left = lv_btn_create(lv_scr_act());
    lv_obj_remove_style_all(btn_top_left);
    lv_obj_add_style(btn_top_left, &style, 0);
    lv_obj_add_style(btn_top_left, &style_pr, LV_STATE_PRESSED);
    lv_obj_set_size(btn_top_left, 120, 60);  // 设置固定大小
    lv_obj_set_pos(btn_top_left, 20, 20);    // 绝对坐标：距离左上角各20px
    
    lv_obj_t * label_tl = lv_label_create(btn_top_left);
    lv_label_set_text(label_tl, "Top Left");
    lv_obj_center(label_tl);

    /* 创建右上角按钮 */
    lv_obj_t * btn_top_right = lv_btn_create(lv_scr_act());
    lv_obj_remove_style_all(btn_top_right);
    lv_obj_add_style(btn_top_right, &style, 0);
    lv_obj_add_style(btn_top_right, &style_pr, LV_STATE_PRESSED);
    lv_obj_set_size(btn_top_right, 120, 60);
    lv_obj_set_pos(btn_top_right, 800 - 120 - 20, 20);  // 800-按钮宽度-右边距
    
    lv_obj_t * label_tr = lv_label_create(btn_top_right);
    lv_label_set_text(label_tr, "Top Right");
    lv_obj_center(label_tr);

    /* 创建左下角按钮 */
    lv_obj_t * btn_bottom_left = lv_btn_create(lv_scr_act());
    lv_obj_remove_style_all(btn_bottom_left);
    lv_obj_add_style(btn_bottom_left, &style, 0);
    lv_obj_add_style(btn_bottom_left, &style_pr, LV_STATE_PRESSED);
    lv_obj_set_size(btn_bottom_left, 120, 60);
    lv_obj_set_pos(btn_bottom_left, 20, 480 - 60 - 20);  // 480-按钮高度-底边距
    
    lv_obj_t * label_bl = lv_label_create(btn_bottom_left);
    lv_label_set_text(label_bl, "Bottom Left");
    lv_obj_center(label_bl);

    /* 创建右下角按钮 */
    lv_obj_t * btn_bottom_right = lv_btn_create(lv_scr_act());
    lv_obj_remove_style_all(btn_bottom_right);
    lv_obj_add_style(btn_bottom_right, &style, 0);
    lv_obj_add_style(btn_bottom_right, &style_pr, LV_STATE_PRESSED);
    lv_obj_set_size(btn_bottom_right, 120, 60);
    lv_obj_set_pos(btn_bottom_right, 800 - 120 - 20, 480 - 60 - 20);  // 右下角
    
    lv_obj_t * label_br = lv_label_create(btn_bottom_right);
    lv_label_set_text(label_br, "Bottom Right");
    lv_obj_center(label_br);
}


//========================== 图标按钮 ============================
lv_obj_t * lv_bling_imgbtn( int x, int y, int w, int h, char * pic_path)
{
    /*Darken the button when pressed and make it wider*/
    //添加按键的样式表，使他有一个动态的效果
    static lv_style_t style_pr; //样式表
    lv_style_init(&style_pr);
    lv_style_set_img_recolor_opa(&style_pr, LV_OPA_30);
    lv_style_set_img_recolor(&style_pr, lv_color_black());
    lv_style_set_transform_height(&style_pr, 20);

    /*Create an image button*/
    lv_obj_t * imgbtn = lv_imgbtn_create(lv_scr_act());
    if(imgbtn == NULL) {
        LV_LOG_ERROR("lv_imgbtn_create fail:"); // 输出错误提示
        return NULL;
    }

    lv_obj_set_size(imgbtn, w, h); 
    lv_imgbtn_set_src(imgbtn, LV_IMGBTN_STATE_RELEASED, NULL, pic_path, NULL);
    // lv_obj_add_style(imgbtn1, &style_def, 0);
    lv_obj_add_style(imgbtn, &style_pr, LV_STATE_PRESSED);

    //(x和h按键偏移的位置)
    lv_obj_align(imgbtn, LV_ALIGN_TOP_LEFT, x, h);

    return imgbtn;
}
//按键的回调函数
static void video_btn_event_callback(lv_event_t * e)
{
    lv_event_code_t code = lv_event_get_code(e);

    //点击按键之后所处理的事情在这个if语句里面实现
    if(code == LV_EVENT_CLICKED) 
    {
        printf("video.png\n");
        // LV_LOG_USER("Clicked");
    }
}

// 显示图像按钮
void test_btn_image()
{
    // 3.在主界面中创建音乐与视频图标(注意：要使用开发板里面的绝对路径 图片的大小是200*200)
    lv_obj_t * video = lv_bling_imgbtn(100, 200, 200, 200, "S:/IOT/bling/qi3.png");
    lv_obj_add_event_cb(video, video_btn_event_callback, LV_EVENT_CLICKED, NULL);
}


//=================================标签=====================================
// 标签函数
void label()
{
    lv_obj_t * label = lv_label_create(lv_scr_act());
    //设置文本内容
    // lv_label_set_text(label, "Hello, LVGL!");
    
    //使能字体的颜色
    lv_label_set_recolor(label, true); 
    lv_label_set_text(label,"#ff0000 hello LVLG#"); //设置文本颜色的格式

    //设置label的大小：
    lv_obj_set_width(label, 300); // 设置宽度为300px
    lv_obj_set_height(label, 50); // 设置高度为50px
        
    //设置字体的大小
    lv_obj_set_style_text_font(label, &lv_font_montserrat_32, 0);  
      
    //设置标签的位置
    lv_obj_set_pos(label,300,60);
}

// 滚动标签
void lv_bling_label_3(void)
{
    lv_obj_t * label = lv_label_create(lv_scr_act());
    //设置标签的模式为滚动的模式
    lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR);     /*Circular scroll*/
    lv_obj_set_width(label, 800);
    lv_label_set_recolor(label, true); 
    //注意：字体显示的内容要超过你自定义的区域大小
    lv_label_set_text(label,"#ff0000 It is a circularly scrolling text.dsakjdhaskjdhkjashdkahdakjshdkasjdhjkshdkj#"); //设置文本颜色的格式   
    lv_obj_set_style_text_font(label, &lv_font_montserrat_32, 0); 
    // lv_label_set_text(label, "It is a circularly scrolling text. ");
    lv_obj_align(label, LV_ALIGN_TOP_LEFT, 0, 100);
}

// ======================GIF========================
/*
    gif动态图的demo
*/
void lv_bling_gif_1()
{
    #if 1
    /*
        如何实现gif动态图的控件
    */
    //显示gif在坐标(200,0)的位置放了一张gif图
    //实例化一个gif的对象
    lv_obj_t *gif1 = lv_gif_create(lv_scr_act());
    //设置gif图的坐标位置
    lv_obj_set_pos(gif1,0,0);
    //lv_obj_align(gif1, LV_ALIGN_RIGHT_MID, -20, 0); //在起始坐标的位置左移20
    //设置gif图的路径
    lv_gif_set_src(gif1,"S:/IOT/bling/gf1.gif");
    printf("show gif\n");
    #endif
}


//=====================msg========================
static void event_cb(lv_event_t * e)
{
    lv_obj_t * obj = lv_event_get_current_target(e);
    LV_LOG_USER("Button %s clicked", lv_msgbox_get_active_btn_text(obj));
    
    const char *ret_str = lv_msgbox_get_active_btn_text(obj);
    
        if (strcmp(ret_str, "Apply") == 0) 
            // 点击了 Apply 按钮
            lv_bling_gif_1();
        if (strcmp(ret_str, "Close") == 0) 
            // 点击了 Close 按钮
            test_btn_image();
}

void lv_bling_msgbox_1(void)
{
    static const char * btns[] = {"Apply", "Close", ""};
    
    lv_obj_t * mbox1 = lv_msgbox_create(NULL, "Hello", "This is a message box with two buttons.", btns, true);
    lv_obj_add_event_cb(mbox1, event_cb, LV_EVENT_VALUE_CHANGED, NULL);
    lv_obj_center(mbox1);
}

//=======================list列表控件===================
/*********************************list列表***********************************/
static lv_obj_t * list1;

static void event_handler(lv_event_t * e)
{
    lv_event_code_t code = lv_event_get_code(e);
    lv_obj_t * obj = lv_event_get_target(e);
    if(code == LV_EVENT_CLICKED) {
        LV_LOG_USER("Clicked: %s", lv_list_get_btn_text(list1, obj));
    }
}

void lv_bling_list_1(void)
{
    /*Create a list*/
    list1 = lv_list_create(lv_scr_act());
    lv_obj_set_size(list1, 180, 220);
    lv_obj_center(list1);

    /*Add buttons to the list*/
    lv_obj_t * btn;

    lv_list_add_text(list1, "File");
    btn = lv_list_add_btn(list1, LV_SYMBOL_FILE, "New");
    lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
    btn = lv_list_add_btn(list1, LV_SYMBOL_DIRECTORY, "Open");
    lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
    btn = lv_list_add_btn(list1, LV_SYMBOL_SAVE, "Save");
    lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
    btn = lv_list_add_btn(list1, LV_SYMBOL_CLOSE, "Delete");
    lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
    btn = lv_list_add_btn(list1, LV_SYMBOL_EDIT, "Edit");
    lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);

    lv_list_add_text(list1, "Connectivity");
    btn = lv_list_add_btn(list1, LV_SYMBOL_BLUETOOTH, "Bluetooth");
    lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
    btn = lv_list_add_btn(list1, LV_SYMBOL_GPS, "Navigation");
    lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
    btn = lv_list_add_btn(list1, LV_SYMBOL_USB, "USB");
    lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
    btn = lv_list_add_btn(list1, LV_SYMBOL_BATTERY_FULL, "Battery");
    lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);

    lv_list_add_text(list1, "Exit");
    btn = lv_list_add_btn(list1, LV_SYMBOL_OK, "Apply");
    lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
    btn = lv_list_add_btn(list1, LV_SYMBOL_CLOSE, "Close");
    lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
}

//========================keys按键============================
static void ta_event_cb(lv_event_t * e)
{
    lv_event_code_t code = lv_event_get_code(e);
    lv_obj_t * ta = lv_event_get_target(e);
    lv_obj_t * kb = lv_event_get_user_data(e);
    if(code == LV_EVENT_FOCUSED) {
        lv_keyboard_set_textarea(kb, ta);
        lv_obj_clear_flag(kb, LV_OBJ_FLAG_HIDDEN);
    }

    if(code == LV_EVENT_DEFOCUSED) {
        lv_keyboard_set_textarea(kb, NULL);
        lv_obj_add_flag(kb, LV_OBJ_FLAG_HIDDEN);
    }
}

// keys键盘
// 键盘示例函数 - 改进版本
void lv_example_keyboard_5(void)
{
    /*创建一个虚拟键盘对象，用于文本输入*/
    lv_obj_t *kb = lv_keyboard_create(lv_scr_act());

    /*创建两个文本区域，键盘可以在它们之间切换输入*/
    
    // 创建第一个文本区域（左上角）
    lv_obj_t * ta_left = lv_textarea_create(lv_scr_act());
    // 对齐到屏幕左上角，距离左边缘10像素，上边缘10像素
    lv_obj_align(ta_left, LV_ALIGN_TOP_LEFT, 10, 10);
    // 添加事件回调，监听焦点变化等事件
    lv_obj_add_event_cb(ta_left, ta_event_cb, LV_EVENT_ALL, kb);
    // 设置占位符提示文字
    lv_textarea_set_placeholder_text(ta_left, "账号");
    // 设置文本区域尺寸：宽140像素，高80像素
    lv_obj_set_size(ta_left, 140, 80);

    // 创建第二个文本区域（右上角）
    lv_obj_t * ta_right = lv_textarea_create(lv_scr_act());
    // 对齐到屏幕右上角，距离右边缘10像素，上边缘10像素
    lv_obj_align(ta_right, LV_ALIGN_TOP_RIGHT, -10, 10);
    // 添加相同的事件回调函数
    lv_obj_add_event_cb(ta_right, ta_event_cb, LV_EVENT_ALL, kb);
    // 设置占位符提示文字
    lv_textarea_set_placeholder_text(ta_right, "密码");
    // 设置文本区域尺寸：宽140像素，高80像素
    lv_obj_set_size(ta_right, 140, 80);

    /*初始时将键盘关联到第一个文本区域*/
    lv_keyboard_set_textarea(kb, ta_left);
}

//=======================style样式====================
    void lv_bling_stylesheet_1(void)
    {
        lv_obj_t*widget = lv_obj_create(lv_scr_act());
        lv_obj_set_size(widget,100,100);
        lv_obj_set_pos(widget, 350, 100);
        //lv_obj_set_align(widget,LV_ALIGN_CENTER); 对象对其方式
    
        //1、定义一个样式变量
        static lv_style_t style;
        //2、初始化变量
        lv_style_init(&style);
        //3、往样式变量中设置背景颜色
        lv_style_set_bg_color(&style,lv_color_hex(0xff0000));
        //4、将样式变量 添加到对象中
        lv_obj_add_style(widget,&style,0);
    }

    // 设置边框
void my_example_style_0(void)
{
        //得到当前屏幕的界面对象
    lv_obj_t*parent = lv_scr_act();
    // int width = lv_obj_get_width(parent);
    // int height = lv_obj_get_height(parent);

    lv_obj_t*btn1 = lv_btn_create(parent);
    lv_obj_set_size(btn1, 100, 100);

    lv_obj_t*btn2 = lv_btn_create(parent);
    lv_obj_set_size(btn2, 100, 100);
    lv_obj_align(btn2, LV_ALIGN_CENTER, 0, 0);

    //初始化样式
    static lv_style_t style;
    lv_style_init(&style);
    lv_style_set_bg_color(&style, lv_color_hex(0xff0000));
    lv_style_set_border_width(&style, 10);
    lv_style_set_border_color(&style, lv_color_hex(0x00ff00));

    //把设置好的样式生效于控件
    lv_obj_add_style(btn1, &style, LV_PART_MAIN);
    lv_obj_add_style(btn2, &style, LV_PART_MAIN);
}


//展示如何创建渐变背景效果

void my_example_style_2(void)
{
    // 定义并初始化样式变量
    static lv_style_t style;
    lv_style_init(&style);
    
    // 设置圆角半径为5像素
    lv_style_set_radius(&style, 5);

    /* 创建渐变背景效果 */
    // 设置背景完全不透明
    lv_style_set_bg_opa(&style, LV_OPA_COVER);
    // 设置背景起始颜色：浅灰色
    lv_style_set_bg_color(&style, lv_palette_lighten(LV_PALETTE_GREY, 1));
    // 设置背景渐变颜色：蓝色
    lv_style_set_bg_grad_color(&style, lv_palette_main(LV_PALETTE_BLUE));
    // 设置渐变方向：垂直方向
    lv_style_set_bg_grad_dir(&style, LV_GRAD_DIR_VER);

    /* 调整渐变位置 */
    // 设置主色停止点位置：128（0-255范围）
    lv_style_set_bg_main_stop(&style, 128);
    // 设置渐变色停止点位置：192（0-255范围）
    lv_style_set_bg_grad_stop(&style, 192);

    /* 创建应用样式的对象 */
    // 创建基础对象
    lv_obj_t * obj = lv_obj_create(lv_scr_act());
    // 将样式应用到对象
    lv_obj_add_style(obj, &style, 0);
    // // 将对象居中显示在屏幕上
    // lv_obj_center(obj);
    lv_obj_set_pos(obj, 200, 100);
}

/**
 * Using the Shadow style properties
 */
void my_example_style_9(void)
{
    static lv_style_t style;
    lv_style_init(&style);

    /*Set a background color and a radius*/
    lv_style_set_radius(&style, 5);
    lv_style_set_bg_opa(&style, LV_OPA_COVER);
    lv_style_set_bg_color(&style, lv_palette_lighten(LV_PALETTE_GREY, 1));

    /*Add a shadow*/
    lv_style_set_shadow_width(&style, 55);
    lv_style_set_shadow_color(&style, lv_palette_main(LV_PALETTE_BLUE));
//    lv_style_set_shadow_ofs_x(&style, 10);
//    lv_style_set_shadow_ofs_y(&style, 20);

    /*Create an object with the new style*/
    lv_obj_t * obj = lv_obj_create(lv_scr_act());
    lv_obj_add_style(obj, &style, 0);
    lv_obj_set_pos(obj, 460, 100);
}



//============================中文字体==========================
static void event_font_handler(lv_event_t * e)
{
    lv_event_code_t code = lv_event_get_code(e);
    if(code == LV_EVENT_PRESSED) {
        printf("ok\n");
    }
}

void font_test_1(void)
{
    /*
    显示中文字的说明:要添加 chinese_ziku.c lv_font_source_han_sans_bold_20.c两个文件   
    */
    //在按键上面显示中文标签
    lv_obj_t * btn1 = lv_btn_create(lv_scr_act());
    lv_obj_set_size(btn1,200,200);
    lv_obj_set_pos(btn1,300,240);
    lv_obj_add_event_cb(btn1, event_font_handler, LV_EVENT_PRESSED, NULL);

    lv_obj_t * wendu = lv_label_create(btn1);
    lv_obj_align(wendu,LV_ALIGN_CENTER,0,0);
    lv_label_set_text(wendu,"请点击");
    //20字体的大小
    lv_obj_set_style_text_font(wendu,&chinese_ziku,0);

    // //20字体的大小粗体 
    // lv_obj_set_style_text_font(wendu,&chinese_ziku,0);
}

void font_test_2(void)
{
    //直接显示中文label标签
     lv_obj_t * label = lv_label_create(lv_scr_act());
    //设置文本内容
    lv_label_set_text(label, "你好世界");
    //设置label的大小：
    lv_obj_set_width(label, 300); // 设置宽度为100px
    lv_obj_set_height(label, 50); // 设置高度为50px        
    //设置字体的大小
    lv_obj_set_style_text_font(label,&chinese_ziku,0);       
    //设置标签的位置
    lv_obj_set_pos(label,350,10);   
    
}


// 显示 PNG 图片
void show_png_image(char* pngphoto)
{
    // 参数检查
    if(pngphoto == NULL || strlen(pngphoto) == 0) {
        LV_LOG_WARN("图片路径为空");
        return;
    }
    
    // 创建图片对象
    lv_obj_t * img_png = lv_img_create(lv_scr_act());
    if(img_png == NULL) {
        LV_LOG_ERROR("创建图片对象失败");
        return;
    }

    // 设置 PNG 图片源
    lv_img_set_src(img_png, pngphoto);  // 文件系统路径
    
    // 或者使用变量（如果图片已转换为C数组）
    // lv_img_set_src(img_png, &your_png_image);
    
    // 设置位置和大小
    lv_obj_set_size(img_png, 800, 480);
    // lv_obj_align(img_png, LV_ALIGN_CENTER, 0, 0);
    lv_obj_set_pos(img_png,0,0); 
    
    // // 设置样式（可选）
    // lv_obj_set_style_radius(img_png, 10, 0);  // 圆角
    // lv_obj_set_style_bg_color(img_png, lv_color_hex(0xffffff), 0);  // 背景色
}

// 显示 JPG 图片  
void show_jpg_image(void)
{
    lv_obj_t * img_jpg = lv_img_create(lv_scr_act());
    lv_img_set_src(img_jpg, "S:/IOT/bling/sample.jpg");
    lv_obj_set_size(img_jpg, 200, 150);
    lv_obj_align(img_jpg, LV_ALIGN_TOP_RIGHT, -20, 20);
}


//=====================定时器==================
//两个按键测试定时器
lv_timer_t * timer1 = NULL;
int sum = 0;
void my_timer_1(lv_timer_t * timer)
{
  /*Use the user_data*/
//   uint32_t * user_data = timer->user_data;
//   printf("my_timer called with user data: %d\n", *user_data);
  printf("%d\n",++sum);

}

static void event_handler_bnt_11(lv_event_t * e) //按键1启动定时器
{
    lv_event_code_t code = lv_event_get_code(e);

    if(code == LV_EVENT_PRESSED) {
        printf("计时开始\n");
        // lv_timer_ready(timer1);  //启动定时器
        lv_timer_resume(timer1); //恢复定时器
    }
}

static void event_handler_bnt_12(lv_event_t * e)//按键2暂停定时器
{
    lv_event_code_t code = lv_event_get_code(e);

    if(code == LV_EVENT_PRESSED) {
        printf("关闭计时器\n");
        // lv_timer_del(timer1); //删除定时器
        lv_timer_pause(timer1); //暂停
    }
}

void timer_button_test(void)
{   
    //初始化一个定时器(每500ms执行一个函数my_timer_1)
    static uint32_t user_data = 10;
    timer1 = lv_timer_create(my_timer_1, 2000,  &user_data);

    lv_obj_t * btn1 = lv_btn_create(lv_scr_act());
    //设置按键btn的size大小200*200
    lv_obj_set_size(btn1,100,100);
    //设置按键btn的位置(400,240)
    lv_obj_set_pos(btn1,600,100);   
    lv_obj_add_event_cb(btn1, event_handler_bnt_11, LV_EVENT_PRESSED, NULL);    
    //显示文字在按键btn上
    lv_obj_t * label1 = lv_label_create(btn1);//实例化一个标签label对象
    lv_label_set_text(label1, "开定时器");//给标签注释
    lv_obj_set_style_text_font(label1,&chinese_ziku,0);    
    lv_obj_center(label1); //将文本放在按键的中间  

    lv_obj_t * btn2 = lv_btn_create(lv_scr_act());
    //设置按键btn的size大小200*200
    lv_obj_set_size(btn2,100,100);
    //设置按键btn的位置(400,240)
    lv_obj_set_pos(btn2,600,300);   
    lv_obj_add_event_cb(btn2, event_handler_bnt_12, LV_EVENT_PRESSED, NULL);    
    //显示文字在按键btn上
    lv_obj_t * label2 = lv_label_create(btn2);//实例化一个标签label对象
    lv_label_set_text(label2, "关定时器");//给标签注释
    lv_obj_set_style_text_font(label2,&chinese_ziku,0); 
    lv_obj_center(label2); //将文本放在按键的中间  

}